# app/settings/config.py

class DefaultConfig:
    """默认配置"""
    # mysql配置
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/toutiao'  # 连接地址
    SQLALCHEMY_TRACK_MODIFICATIONS = False  # 是否追踪数据变化
    SQLALCHEMY_ECHO = False  # 是否打印底层执行的SQL
    SQLALCHEMY_BINDS = {  # 主从数据库的URI
        "master": 'mysql://root:mysql@127.0.0.1:3306/toutiao',
        "slave1": 'mysql://root:mysql@127.0.0.1:3306/toutiao',
        "slave2": 'mysql://root:mysql@127.0.0.1:8306/toutiao'
    }

    # redis配置
    # REDIS_HOST = '127.0.0.1'  # ip
    # REDIS_PORT = 6381  # 端口
    # redis集群配置
    CLUSTER_NODES = [  # 集群中主数据库的ip和端口号
        {'host': '127.0.0.1', 'port': 7000},
        {'host': '127.0.0.1', 'port': 7001},
        {'host': '127.0.0.1', 'port': 7002},
    ]
    # 设置哨兵的ip和端口
    SENTINEL_LIST = [
        ('127.0.0.1', 26380),
        ('127.0.0.1', 26381),
        ('127.0.0.1', 26382),
    ]

    SERVICE_NAME = 'mymaster'  # 哨兵配置的主数据库别名
    # JWT
    JWT_SECRET = 'TPmi4aLWRbyVq8zu9v82dWYW17/z+UvRnYTt4P6fAXA'  # 秘钥
    JWT_EXPIRE_DAYS = 14  # JWT过期时间

config_dict = {
    'dev': DefaultConfig
}


